<?php
namespace Modules\Admin\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\Facades\DB;
class RedisController extends CommonController
{
	/**
     * 首页
     */
    public function redis(Request $request)
    {
		//Redis::ltrim("user_list",1,0);     //删除队列中的所有元素
		Redis::lpush('user_list',range(1,100));
		return Redis::llen("user_list");
		return Redis::lrange('user_list' , 0 , -1); //查看队列所有的元素
		//$redis->set('foo1',123);
		//return Redis::llen("user_list");
		//return Redis::ltrim("user_list",0,0);
		//return Redis::rpop("user_list");
		$redis_info = DB::table('redis')->orderBy('id','desc')->first();
		if(!$redis_info){
			$number = range(1,100);
			Redis::lpush('user_list',$number);
		}
		$order_no = Redis::rpop("user_list");
		DB::table('redis')->insert(['order_no'=>$order_no]);
		return $order_no;
    }
	
}
